// 基于对象的 constructor
function myInstanceof(obj, type) {
  if (obj == null || obj == undefined) {
    return false;
  }
  if (typeof obj === "object" || typeof obj == "function") {
    return obj.constructor === type ? true : myInstanceof(obj.__proto__, type);
  }

  return false;
}

// 基于构造函数的 prototype
function MyInstanceof(obj, type) {
  if (obj == null || obj == undefined) {
    return false;
  }
  if (typeof obj === "object" || typeof obj == "function") {
    return type.prototype === obj ? true : MyInstanceof(obj.__proto__, type);
  }
  return false;
}
